USE RestaurantBooker
go

/*update room set room_background=
(SELECT * FROM OPENROWSET(BULK N'D:\Work\Projects\KodiSoft\TestWorks\trunk\Resources\r21.png', SINGLE_BLOB) as rs)
where room_id = 1;
*/

-- delete  all tables from firs room
delete  from Room_Table where room_id = 1;

------------------------------------
-- CLEAR room_plases to first room
------------------------------------

DELETE  from  Table_Place
WHERE EXISTS
(SELECT 'ye' FROM Room_Table as rt
	where Table_Place.room_table_id = rt.room_table_id)
go


DECLARE @lastRomTable_id int = 0;

-- insert tables
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           (
           [room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           (
           '01'
           ,1
           ,155
           ,27
           ,97
           ,77);

 

set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('5', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('6', @lastRomTable_id , 0, 0,  -1, -1);



           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('02'
           ,1
           ,40
           ,27
           ,97
           ,77);



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('5', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('6', @lastRomTable_id , 0, 0,  -1, -1);

           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('03'
           ,1
           ,36
           ,118
           ,103
           ,60);


set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);

           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('04'
           ,1
           ,36
           ,200
           ,103
           ,60);          




set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);

           
           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('05'
           ,1
           ,36
           ,275
           ,103
           ,60); 



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);

           
           
                     
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('06'
           ,1
           ,35
           ,354
           ,104
           ,77);



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('5', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('6', @lastRomTable_id , 0, 0,  -1, -1);


           
           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('07'
           ,1
           ,155
           ,140
           ,95
           ,95); 



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);



INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('08'
           ,1
           ,155
           ,236
           ,95
           ,95);        
                          


set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);



INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('09'
           ,1
           ,155
           ,336
           ,95
           ,95);  
           
           


set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);

           

           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('10'
           ,1
           ,375
           ,205
           ,82
           ,106); 
           


set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);


           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('11'
           ,1
           ,375
           ,330
           ,82
           ,106);
           


set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);


    
           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
          ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('12'
           ,1
           ,475
           ,205
           ,82
           ,106); 



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);


    
           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('13'
           ,1
           ,475
           ,330
           ,82
           ,106);           



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);

  
           
                                           
           
INSERT INTO [RestaurantBooker].[dbo].[Room_Table]
           ([room_table_name]
           ,[room_id]
           ,[room_table_x]
           ,[room_table_y]
           ,[room_table_width]
           ,[room_table_height])
     VALUES
           ('14'
           ,1
           ,452
           ,77
           ,97
           ,77);



set @lastRomTable_id = (select scope_identity());

-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('1', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('2', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('3', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('4', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('5', @lastRomTable_id , 0, 0,  -1, -1);
-- Insert room_plases 
INSERT INTO [RestaurantBooker].[dbo].[Table_Place] ([table_place_name],[room_table_id],[table_place_width],[table_place_height],[table_place_x],[table_place_y])
VALUES ('6', @lastRomTable_id , 0, 0,  -1, -1);


                      









/****************************************************************************
Second room for firs restaurant
*****************************************************************************/

/*update room set room_background=
(SELECT * FROM OPENROWSET(BULK N'D:\Work\Projects\KodiSoft\TestWorks\trunk\Resources\r22.png', SINGLE_BLOB) as rs)
where room_id = 6;*/

GO

